<?php /*a:2:{s:50:"D:\www\file\application\admin\view\role\index.html";i:1594695049;s:44:"D:\www\file\application\admin\view\head.html";i:1594869155;}*/ ?>
<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <title>后台登录-X-admin2.2</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="/static/admin/css/font.css">
    <link rel="stylesheet" href="/static/admin/css/xadmin.css">

    <!-- <link rel="stylesheet" href="./css/theme5.css"> -->
    <script src="/static/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
    <script src="/static/admin/js/jquery.min.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script>
        // 是否开启刷新记忆tab功能
        // var is_remember = false;
    </script>
</head>


<html class="x-admin-sm">
    <body>
        <div class="x-nav">

          <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">
                        </div>
                            <div class="layui-card-header">
                                <button class="layui-btn" onclick="xadmin.open('添加角色','<?php echo url('admin/role/create'); ?>')"><i class="layui-icon"></i>添加</button>
                            </div>
                        <div class="layui-card-body ">
                            <table class="layui-table layui-form" >
                              <thead>
                                <tr >
                                  <th style="text-align: center">ID</th>
                                  <th style="text-align: center">角色</th>
                                  <th style="text-align: center">拥有权限</th>
                                  <th style="text-align: center">操作</th>
                                </tr>
                              </thead>
                              <tbody>
                              <?php foreach($data as $v): ?>
                              <tr >

                                  <td style="width: 8%"><?php echo htmlentities($v['id']); ?></td>
                                  <td style="width: 20%" ><?php echo htmlentities($v['role_name']); ?></td>
                                  <td style="width: 57%"><?php echo htmlentities($v['role_auth_ids']); ?></td>
                                  <td style="width: 15%">
                                      <a title="分配权限"  onclick="xadmin.open('分配权限','<?php echo url('setauth',['id' => $v['id']]); ?>')" href="javascript:;">
                                          <button type="button" class="layui-btn layui-btn-normal layui-btn-radius">分配权限</button>
                                      </a>


                                      <a title="删除" onclick="member_del(this,'<?php echo htmlentities($v['id']); ?>')"  href="javascript:;">
                                          删除
                                      </a>
                                  </td>

                              </tr>
                              <?php endforeach; ?>
                              </tbody>
                            </table>
                        </div>

                    </div>
                </div>
            </div>
        </div> 
    </body>

    <script>
        layui.use(['laydate','form','table'], function(){
            var laydate = layui.laydate;
            var form = layui.form;
            var table = layui.table;

            //执行一个laydate实例
            laydate.render({
                elem: '#start' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end' //指定元素
            });

            //方法级渲染



        });

        /*用户-删除*/
        function member_del(obj,id){

            layer.confirm('确认要删除吗？',function(index){
                $.ajax({
                    url:"<?php echo url('admin/role/delete'); ?>",
                    type:"get",
                    data:'id=' + id,
                    success:function (callback) {
                        //发异步删除数据
                        if (callback.msg == 201){
                            $(obj).parents("tr").remove();
                            layer.msg('已删除!',{icon:1,time:1000});
                        }else if (callback.msg == '权限不足，禁止访问'){
                            layer.msg('权限不足，禁止访问!',{icon:2,time:1000});
                        }else if (callback.msg == 203){
                            layer.msg('超级管理员禁止删除!',{icon:2,time:1000});
                        }
                        else {
                            layer.msg('删除失败!',{icon:2,time:1000});
                        }
                    }

                });

            });
        }




    </script>


</html>